package com.huabo.sql.page;

/**
 * Created by Jackie Liu on 2017/6/29.
 */
public class PostgresqlPage implements PageSql {

    @Override
    public String getSql(String prefixSql, int pageNum, int pageSize) {
        int offset = 0, size = 0, num = 0;
        size = pageSize > 0 ? pageSize : 20;
        num = pageNum > 0 ? pageNum : 1;
        offset = (num - 1) * size;

        return String.format("%s LIMIT %d OFFSET %d", prefixSql, size, offset);

        //SELECT * FROM test_table WHERE i_id>10000000 limit 100;高效的分页语句
    }

}
